/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package bean;

/**
 *
 * @author Alex
 */
public class Calculette {

    private String operande1; //r w
    private String operande2; //r w
    private String resultat; //r ("Err" si erreur)
    private String operation; //w

    public Calculette(String operande1, String operande2, String operation) {
        this.operande1 = operande1;
        this.operande2 = operande2;
        this.operation = operation;
    }

    public String getOperande1() {
        return operande1;
    }

    public void setOperande1(String operande1) {
        this.operande1 = operande1;
    }

    public String getOperande2() {
        return operande2;
    }

    public void setOperande2(String operande2) {
        this.operande2 = operande2;
    }

    public String getResultat() {

        int op1 = Integer.parseInt(operande1);
        int op2 = Integer.parseInt(operande2);

        int res = 0;

        if(operation.equals("+"))
            res = op1 + op2;

         if(operation.equals("-"))
            res = op1 - op2;

         if(operation.equals("*"))
            res = op1 * op2;

         if(operation.equals("/"))
            res = op1 / op2;

        resultat = String.valueOf(res);

        return resultat;
    }

    public void setOperation(String operation) {
        this.operation = operation;
    }

         

}
